<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电影评论框</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css" rel="stylesheet">
    <style>
        /* 评论框整体样式 */
        .comment-box {
            background: #ffffff;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            padding: 25px;
            margin: 20px 0;
            transition: box-shadow 0.3s ease;
        }

        .comment-box:hover {
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
        }

        /* 标题样式 */
        .comment-title {
            font-size: 24px;
            font-weight: 600;
            color: #333;
            margin-bottom: 20px;
            border-bottom: 2px solid #007bff;
            display: inline-block;
            padding-bottom: 5px;
        }

        /* 输入框样式 */
        .comment-form .form-control {
            border-radius: 8px;
            border: 1px solid #e0e0e0;
            padding: 12px;
            font-size: 16px;
            color: #333;
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }

        .comment-form .form-control:focus {
            border-color: #007bff;
            box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);
            outline: none;
        }

        /* 按钮样式 */
        #submit-comment {
            background: #007bff;
            border: none;
            border-radius: 8px;
            padding: 10px 25px;
            font-size: 16px;
            font-weight: 500;
            color: #fff;
            cursor: pointer;
            transition: background 0.3s ease, transform 0.2s ease;
        }

        #submit-comment:hover {
            background: #0056b3;
            transform: translateY(-2px);
        }

        #submit-comment:active {
            transform: translateY(0);
        }

        /* 表情选择器样式 */
        .emoji-picker {
            margin-top: 10px;
        }

        .emoji-list {
            display: flex;
            flex-wrap: wrap;
            margin-top: 10px;
        }

        .emoji-list span {
            cursor: pointer;
            font-size: 24px;
            margin: 5px;
            padding: 5px;
            border-radius: 50%;
            transition: background 0.3s ease;
        }

        .emoji-list span:hover {
            background: #e0e0e0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="comment-box">
            <h3 class="comment-title">发表评论</h3>
            <div class="comment-form">
                <div class="form-group">
                    <textarea id="comment-content" class="form-control" rows="5" placeholder="写下你的评论..."></textarea>
                </div>
                <div class="form-group text-right">
                    <button id="submit-comment" class="btn btn-primary">提交评论</button>
                </div>
            </div>
            <div class="emoji-picker">
                <button id="toggle-emoji-picker" class="btn btn-secondary">插入表情</button>
                <div id="emoji-list" class="emoji-list" style="display: none;">
                    <!-- 表情符号将动态插入到这里 -->
                </div>
            </div>
        </div>
    </div>

    <script>
        const emojis = [
            '😊', '😢', '👍', '👎', '😂', '😍', '🤔', '😎', '😢', '😭',
            '👏', '🙌', '👏', '👏', '👏', '👏', '👏', '👏', '👏', '👏'
        ];

        document.addEventListener('DOMContentLoaded', function () {
            const commentContent = document.getElementById('comment-content');
            const emojiPicker = document.getElementById('emoji-picker');
            const toggleEmojiPicker = document.getElementById('toggle-emoji-picker');
            const emojiList = document.getElementById('emoji-list');

            // 初始化表情选择器
            emojis.forEach(emoji => {
                const emojiSpan = document.createElement('span');
                emojiSpan.textContent = emoji;
                emojiSpan.addEventListener('click', () => {
                    commentContent.value += emoji;
                    commentContent.focus();
                });
                emojiList.appendChild(emojiSpan);
            });

            // 切换表情选择器显示/隐藏
            toggleEmojiPicker.addEventListener('click', () => {
                emojiList.style.display = emojiList.style.display === 'none' ? 'flex' : 'none';
            });

            document.getElementById('submit-comment').addEventListener('click', function () {
                const commentContent = document.getElementById('comment-content').value;
                if (commentContent.trim() === "") {
                    alert("评论内容不能为空！");
                    return;
                }
                console.log("提交评论：", commentContent);
                alert("评论提交成功！"+commentContent);
                document.getElementById('comment-content').value = ""; // 清空输入框
            });
        });
    </script>
</body>
</html>